#include <regx52.h>
#include "delay.h"
                     
unsigned int note[] = {190, 170, 150, 143, 127, 113, 100};


char LiangZhiLaoHu[] = {
	0,1,2,0,
	0,1,2,0,
	2,3,4,4,
	2,3,4,4,'.',
	4,5,4,3,2,0,
	4,5,4,3,2,0,
	1,-4,0,0,
	1,-4,0,0,
};
char XiaoXingXing[5] = {1,2,3,4,5};


unsigned char current = 0;
unsigned long count = 0;
unsigned char pause = 0;

void play_music(unsigned int num) 
{

	char n = LiangZhiLaoHu[current];
	unsigned int T = 0;
	
	if(pause) return;
		
	if(n<0) 
	{
		T = note[-n] + 80;
	} else 
	{
		T = note[n];
	}
	if(n == '.') {
		T = 100;
	} else 
	{
		P1_5 = !P1_5;
	}
	delay(T);
	count++;
	if(count * T  > 30000) 
	{
		count = 0;
		current++;
		if(current >= num) 
		{
			current = 0;
		}
	}
}